<template>
  <div style="min-height: 100vh; background-color: #f5f5f7">
    <div class="success-warp" v-if="orderStatus === 'success'">
      <CheckCircleFilled :style="{ fontSize: '90px', color: '#2ecc71' }" />
      <div style="font-size: 28px; color: #333; margin-top: 20px;">恭喜你，报名成功！</div>
      <div style="font-size: 16px; color: #666; margin-top: 20px;">
        <div>姓 名：{{ orderInfo.name }}</div>
        <div>身份证：{{ orderInfo.idCard }}</div>
        <div>代收费：{{ orderInfo.collectFees }}元</div>
        <div>住宿费：{{ orderInfo.accDation }}元</div>
      </div>
    </div>

    <div class="success-warp" v-if="orderStatus === 'progress'">
      <SyncOutlined spin :style="{ fontSize: '90px', color: '#2ecc71' }" />
      <div style="font-size: 28px; color: #333; margin-top: 20px;">支付中...</div>
      <div style="font-size: 16px; color: #666; margin-top: 20px;">
        <div>姓 名：{{ orderInfo.name }}</div>
        <div>身份证：{{ orderInfo.idCard }}</div>
        <div>代收费：{{ orderInfo.collectFees }}元</div>
        <div>住宿费：{{ orderInfo.accDation }}元</div>
      </div>
    </div>

    <div class="success-warp" v-if="orderStatus === 'error'">
      <CloseCircleFilled :style="{ fontSize: '90px', color: '#DF1C1C' }" />
      <div style="font-size: 28px; color: #333; margin-top: 20px;">{{ errorMessage }}</div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { CheckCircleFilled, SyncOutlined, CloseCircleFilled } from '@ant-design/icons-vue';
import { queryBmInfoByOrderNo } from './Baoming.api'
import { $ref } from 'vue/macros'
import { nextTick, onMounted, onUnmounted, computed, reactive } from 'vue'
import { useIntervalFn } from '@vueuse/core'
import { useRouter } from 'vue-router'
import { Affix } from 'ant-design-vue'
import { string } from 'vue-types';

const { currentRoute } = useRouter()

let loading = $ref(false)

let outTradeNo = $ref<string>()
let orderInfo = $ref<any>()
let orderStatus = $ref<string>('')
let errorMessage = $ref<string>('')

async function initData() {
  loading = true;
  queryBmInfoByOrderNo({
    bizOrderNo: outTradeNo
  }).then(res => {
    if (res.data) {
      orderStatus = res.data.status;
    } else {
      orderStatus = 'error';
      errorMessage = '报名信息查询为空';
    }
    orderInfo = res.data;
  }).catch(err => {
    orderStatus = 'error';
    errorMessage = '报名信息查询失败';
  }).finally(() => {
    loading = false;
  })
}

/**
 * 入口
 */
onMounted(() => {
  let query = currentRoute.value.query;
  outTradeNo = query ? query.out_trade_no || '' : '';

  if (outTradeNo) {
    initData()
  }
})
/**
 * 出口
 */
onUnmounted(() => {
})
</script>

<style scoped lang="less">
.success-warp {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30% 0;
}
</style>
